package com.like.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.like.entity.PopupBase;
import com.like.hospitalworld.R;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

public class PopupAdapter extends BaseAdapter {

    private List<PopupBase> mPopups;

    @Override
    public int getCount() {
        return mPopups.size();
    }

    @Override
    public Object getItem(int position) {
        return mPopups.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        PopupBase popupBase = (PopupBase) getItem(position);
        ViewHolder vh;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_popup_item, parent, false);
            vh = new ViewHolder(convertView);
            convertView.setTag(vh);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }
        vh.sOption.setText(popupBase.name);
        return convertView;
    }

    public class ViewHolder {
        @ViewInject(R.id.option)
        TextView sOption;

        public ViewHolder(View convertView) {
            x.view().inject(this, convertView);
        }
    }

}
